
<%= form_for @changeset, @action, [multipart: true, novalidate: true, id: "js-announcement-form"], fn f -> %>
  <div class="row row-cards row-deck mt-md-5">
    <div class="col-md-9">
      <div class="card profile">
        <div class="card-body p-6">

          <h4 class="fw-bold"><%= gettext "Create posts" %></h4>

          <div class="pl-4 field-list">
            <%= h_input(f, :title, label: gettext("Title")) %>
            <%= h_input(f, :slug, label: gettext("Slug")) %>
          </div>

          <%= input(f, :content, using: :hidden_input, id: "editor-content",label: gettext("Content")) %>
          <trix-editor input="editor-content" style="min-height: 500px;"></trix-editor>

          <%= input(f, :excerpt, using: :textarea, rows: 3, label: gettext("Short Description")) %>
        </div>
      </div>
    </div>

    <div class="col-md-3">
      <div class="card flex-grow-0">
        <div class="card-body">
          <% meta = get_post_meta(@conn)%>
          <%= input(f, :name, using: :selectize, name: "post[categories][]", label: gettext("Categories"), source: Enum.map(@categories, & &1.name), multiple: true, value: meta.categories) %>
          <%= input(f, :name, using: :selectize, name: "post[tags][]", label: gettext("Tags"), source: Enum.map(@tags, & &1.name), multiple: true, value: meta.tags) %>

          <%= input(f, :date, using: :datepicker, label: gettext("Publish date"), format: "{YYYY}-{0M}-{0D}") %>

          <label class="custom-switch">
            <input name="<%= input_name(f, :draft) %>" type="hidden" value="false">
            <input type="checkbox" name="<%= input_name(f, :draft) %>" <%= input_value(f, :draft) and "checked=\"true\"" %>" value="true" class="custom-switch-input">
            <span class="custom-switch-indicator"></span>
            <span class="custom-switch-description"><%= gettext "Draft" %></span>
          </label>

          <div class="mt-7">
            <button type="submit" class="btn btn-primary"> <i class="fe fe-save mr-1"></i>
              <%= if assigns[:post] do
              gettext "Update"
              else
              gettext "Save"
              end %></button>
          </div>
        </div>
      </div>
      <div class="card flex-grow-0">
        <div class="card-header">
          <h3 class="card-title"><%= gettext "Cover photo" %></h3>
        </div>
        <div class="card-body" id="cover-upload-box" data-name="<%= input_name(f, :cover) %>" data-url="<%= assigns[:post] && @post.cover %>">

        </div>
      </div>
    </div>
  </div>
<% end %>
